#include "toolLib.h"

/*
BOOL validUtf8(char c)
{
    if ((0 <= c && c < utf8SurrogateMin) || (utf8SurrogateMax < c <= utf8MaxChar))
    {
        return TRUE;
    }
    return FALSE;
}
*/

//actually we can't support utf-8
BOOL validDelim(char delim)
{
    return delim != 0 && delim != '"' && delim != '\r' && delim != '\n';
}

int lengthNL(char *line, int len)
{
    if (len > 0 && line[len - 1] == '\n')
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

BOOL ChargeEmptyLine(char *line, int len)
{
    if (len == lengthNL(line, len))
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}

int strchrnum(char *str, char ch)
{
    int num = 0;
    char *ptr = NULL;
    if (str != NULL)
    {
        ptr = str;
        while (*ptr != '\0')
        {
            if (*ptr == ch)
            {
                num++;
            }
            ptr++;
        }
    }
    return num;
}